package com.beimihu.until;

import java.util.Scanner;

public class Epic7Damage {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        // 获取用户输入的各项参数值
        System.out.print("请输入面板攻击: ");
        double panelAttack = scanner.nextDouble();

        System.out.print("请输入爆伤: ");
        double critDamage = scanner.nextDouble();

        System.out.print("请输入神器提供增伤系数: ");
        double artifactDamageBonus = scanner.nextDouble();

        System.out.print("是否有狂气 buff（true/false）: ");
        boolean hasRageBuff = scanner.nextBoolean();

        System.out.print("是否有攻击 buff（true/false）: ");
        boolean hasAttackBuff = scanner.nextBoolean();

        System.out.print("请输入贯穿系数: ");
        double penetrationCoefficient = scanner.nextDouble();

        System.out.print("请输入敌人防御: ");
        double enemyDefense = scanner.nextDouble();

        System.out.print("请输入敌人减伤: ");
        double enemyDamageReduction = scanner.nextDouble();

        // 计算攻击
        double attackCoefficient = calculateAttackCoefficient(hasRageBuff, hasAttackBuff);
        double attack = panelAttack * attackCoefficient;

        // 假设参数
        double baseRate = 1; // 基础倍率
        double fixedDamage = 0; // 固定值伤害
        double powValue = 1; // pow! 倍率修正值
        double attributeTypeCoefficient = 1; // 属性类型系数（非属性克制）
        double strikeTypeCoefficient = critDamage / 100; // 打击类型系数（暴击）
        double conditionBonusCoefficient = 1 + artifactDamageBonus; // 条件收益系数

        // 计算伤害
        double damage = calculateDamage(attack, baseRate, fixedDamage, powValue,
                conditionBonusCoefficient, attributeTypeCoefficient, strikeTypeCoefficient,
                enemyDefense, penetrationCoefficient, enemyDamageReduction);

        System.out.println("伤害值为: " + damage);
        scanner.close();
    }

    // 计算攻击系数
    public static double calculateAttackCoefficient(boolean hasRageBuff, boolean hasAttackBuff) {
        double coefficient = 1;
        if (hasRageBuff) {
            coefficient += 0.2; // 狂气 buff 攻击系数
        }
        if (hasAttackBuff) {
            coefficient += 0.5; // 攻击 buff 攻击系数（假设为1 + 50%的攻击 buff）
        }
        return coefficient;
    }

    // 计算伤害值
    public static double calculateDamage(double attack, double baseRate, double fixedDamage,
                                         double powValue, double conditionBonusCoefficient,
                                         double attributeTypeCoefficient, double strikeTypeCoefficient,
                                         double enemyDefense, double penetrationCoefficient,
                                         double enemyDamageReduction) {
        double constant = 1.871;
        double numerator = (attack * baseRate + fixedDamage) * (constant * powValue)
                * conditionBonusCoefficient * attributeTypeCoefficient * strikeTypeCoefficient;
        double denominator = enemyDefense * penetrationCoefficient / 300 + 1;
        return numerator / denominator * (1 - enemyDamageReduction);
    }
}
